<template>
  <div>
    <el-table
      :data="tableData"
      border
      height="250"
      style="width: 100%">
      <!--定义列
          label="日期"：列表头名称、
          width="180"：列宽度
          prop="date" ：填充列属性名
      -->
      <el-table-column
        fixed
        prop="date"
        label="日期"
        width="180">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
      <el-table-column
        fixed="right"
        label="操作"
        width="100">
        <template slot-scope="scope">
          <el-button type="text" size="small">删除</el-button>
          <el-button type="text" size="small">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>

  </div>
</template>

<script>
  //导入axios来发送Ajax请求
  import axios from "axios"
  export default {
    name: '02_table',
    data () { //导出数据就可以在html中通过{{}}
      return {//对象
        tableData:[]
      }
    },
    methods:{
      getDepartments(){
        //发请求获取数据
        let param = {"currentPage":1,"pageSize":5};
        axios.post("/user/list",param)
          .then(result=>{ //200
            console.log(result)
            this.tableData =result.data.data;
          })
          .catch(result=>{//报错 500 404
            console.log(result)
          })
      }
    },
    mounted(){
      this.getDepartments();
    }
  }
</script>

